home *** CD-ROM | disk | FTP | other *** search
/ Delphi 2.0 - Programmer's Utilities Power Pack / Delphi 2.0 Programmer's Utilities Power Pack.iso / a_to_d / dosvalu / dosvalu.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-09-15  |  1.3 KB  |  65 lines

  1. unit Dosvalu;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs;
  8.  
  9. type
  10.   TDosEnv = class(TComponent)
  11.   private
  12.      FDosIn : String;
  13.      FDosVal: String;
  14.      procedure SetDosIn(Value : string);
  15.      procedure SetDosVal(Value : string);
  16.   published
  17.      property DosEnv: string read FDosIn  write SetDosIn;
  18.      property DosVal: string read FDosVal write SetDosVal;
  19.     { Published declarations }
  20.   end;
  21.  
  22. procedure Register;
  23.  
  24. implementation
  25.  
  26. procedure Register;
  27. begin
  28.   RegisterComponents('Freeware', [TDosEnv]);
  29. end;
  30.  
  31. procedure TDosEnv.SetDosIn(Value : string);
  32. begin
  33.      FDosIn := Value;
  34.      SetDosVal(value);
  35. end;
  36.  
  37. procedure TDosEnv.SetDosVal(Value : string);
  38. var
  39.    P : PChar;
  40.    S : String;
  41.    E : String;
  42. begin
  43.    FDosVal := '';
  44.    if Length(FDosIn) > 0 then
  45.      begin
  46.        P := GetDOSEnvironment;
  47.        while P[0] <> #0 do
  48.          begin
  49.             S := StrPas(P);
  50.             E := S;
  51.             S := Copy(UpperCase(S), 1, Length(FDosIn) + 1);
  52.             if S = UpperCase(FDosIn) + '=' then
  53.               begin
  54.                 FDosVal := Copy(E, Length(FDosIn) + 2, Length (E));
  55.               end;
  56.             P := StrEnd(P) + 1;
  57.          end;
  58.      end
  59.    else
  60.      FDosVal := '';
  61.  
  62. end;
  63.  
  64. end.
  65.